<%-- 
    Document   : EditBook
    Created on : Mar 10, 2014, 11:30:04 AM
    Author     : mishra
--%>

<%@page import="BookType.BookTypeBean"%>
<%@page import="BookCategory.BookCategoryBean"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Vector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    try {
        if (session.getAttribute("uid") != null) {
            if (session.getAttribute("Books").toString().equals("1")) {
%>
<!DOCTYPE html>
<html>
    <head>
        <title>Ramgovind Automated System</title>

        <link rel="stylesheet" href="/RIT/css/bootstrap.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="/RIT/css/jquery.fancybox.css">
        <link rel="stylesheet" href="/RIT/css/style.css">
        <link rel="stylesheet" href="/RIT/css/iconfont.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap.datepicker.css">
        <script src="../../ajax/ajax.js"></script>
        <script>
            function getBookType(cid)
            {
                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                { 
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    { 
                        document.getElementById('btype').innerHTML = xmlhttp.responseText;
                    }
                }
                xmlhttp.open("POST","/RIT/getBookType?cid="+cid,false);
                xmlhttp.send();
            }
        </script>
    </head>
    <body>
        <%@include file="/topheader.html" %>
        <%@include file="/settingheader.html" %>
        <div class="main">
            <div class="container-fluid">
                <%@include file="/Settings/dbsidenav.html" %>
                <div class="content">
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="box">
                                <div class="box-head">
                                    <h3>Add Books</h3>
                                    <a href="Books.jsp">
                                        <button style="float: right" class="btn btn-success">View Books</button>
                                    </a>
                                </div>
                                <form action="/RIT/EditBook" method="post" class='validate form-horizontal'>
                                    <div class="box-content">
                                        <!---Form Start....-->
                                        <div id="lside" style="float: left; margin-top: 10px;">
                                         <div class="control-group">
                                            <label for="bcat" class="control-label">Book Category</label>
                                            <div class="controls">
                                                <select name="bcat" id="bcat" class='{required:true}' onchange="getBookType(this.value)">
                                                    <option value="<%=request.getParameter("cid")%>"><%=request.getParameter("cval")%></option>
                                                    <%
                                                        
                                                        
                                                        Vector<Object> list=BookCategory.Query.viewAll();
                                                        Iterator it = list.iterator();
                                                        while (it.hasNext()) {
                                                            BookCategoryBean bcb=(BookCategoryBean) it.next();

                                                    %>
                                                    <option value="<%=bcb.getBookCategoryId()%>"><%=bcb.getBookCategory()%></option>
                                                    <%}%>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="control-group">
                                            <label for="btype" class="control-label">Book Type</label>
                                            <div class="controls">
                                                <select name="btype" id="btype" class='{required:true}'>
                                                    <option value="<%=request.getParameter("btid")%>"><%=request.getParameter("btval")%></option>
                                                </select>
                                            </div>
                                        </div>        
                                            <div class="control-group">
                                                <label for="bname" class="control-label">Book Name</label>
                                                <div class="controls">
                                                    <input type="text" name="bname" id="bname" class='required' value="<%=request.getParameter("bname")%>">
                                                    <input type="hidden" name="bookid" id="bookid" value="<%=request.getParameter("bid")%>">
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="pname" class="control-label">Publisher Name</label>
                                                <div class="controls">
                                                    <input type="text" name="pname" id="pname" class='required' value="<%=request.getParameter("publisher")%>">
                                                </div>
                                            </div>
                                        <div class="control-group">
                                            <label for="aname" class="control-label">Author Name</label>
                                            <div class="controls">
                                                <input type="text" name="aname" id="aname" class='required' value="<%=request.getParameter("author")%>">
                                            </div>
                                        </div>
                                        <div class="control-group">
                                            <label for="pyear" class="control-label">Publish Year</label>
                                            <div class="controls">
                                                <input type="text" name="pyear" id="pyear" class='required' value="<%=request.getParameter("year")%>">
                                            </div>
                                        </div>
                                    </div>
                                    <div id="rside" style="float: right; margin-right: 120px; margin-top: 10px">
                                        <div class="control-group">
                                            <label for="qty" class="control-label">Quantity</label>
                                            <div class="controls">
                                                <input type="text" name="qty" id="qty" class='required' value="<%=request.getParameter("qty")%>">
                                            </div>
                                        </div>
                                        <div class="control-group">
                                            <label for="price" class="control-label">Price</label>
                                            <div class="controls">
                                                <div class="input-append">
                                                    <input type="text" name="price" id="price" class='{required:true}' value="<%=request.getParameter("price")%>">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="control-group">
                                            <label for="fine" class="control-label">fine</label>
                                            <div class="controls">
                                                <div class="input-append">
                                                    <input type="text" name="fine" id="fine"  class='{required:true}' value="<%=request.getParameter("fine")%>">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="control-group">
                                            <label for="grace" class="control-label">Grace Period</label>
                                            <div class="controls">
                                                <div class="input-append">
                                                    <input type="text" name="grace" id="grace" class='{required:true}' value="<%=request.getParameter("grace")%>">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="control-group">
                                            <label for="isbn" class="control-label">ISBN</label>
                                            <div class="controls">
                                                <div class="input-append">
                                                    <input type="text" name="isbn" id="isbn" class='{required:true}' value="<%=request.getParameter("isbn")%>">
                                                </div>
                                            </div>
                                        </div>
                                         <div class="control-group">
                                            <label for="bdesc" class="control-label">Book Description</label>
                                            <div class="controls">
                                                <div class="input-append">
                                                    <textarea type="text" name="bdesc" id="bdesc"><%=request.getParameter("desc")%></textarea>
                                                </div>
                                            </div>
                                        </div>       
                                    </div>
                                    </div>
                                    <div class="form-actions">
                                        <input type="submit" class='btn btn-primary'>
                                    </div>
                                </form>
                                <!---Form Ends....-->
                            </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <script src="/RIT/js/jquery.js"></script>
        <script src="/RIT/js/less.js"></script>
        <script src="/RIT/js/bootstrap.min.js"></script>
        <script src="/RIT/js/jquery.uniform.min.js"></script>
        <script src="/RIT/js/bootstrap.timepicker.js"></script>
        <script src="/RIT/js/bootstrap.datepicker.js"></script>
        <script src="/RIT/js/chosen.jquery.min.js"></script>
        <script src="/RIT/js/jquery.fancybox.js"></script>
        <script src="/RIT/js/plupload/plupload.full.js"></script>
        <script src="/RIT/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
        <script src="/RIT/js/jquery.cleditor.min.js"></script>
        <script src="/RIT/js/jquery.inputmask.min.js"></script>
        <script src="/RIT/js/jquery.tagsinput.min.js"></script>
        <script src="/RIT/js/jquery.mousewheel.js"></script>
        <script src="/RIT/js/jquery.textareaCounter.plugin.js"></script>
        <script src="/RIT/js/ui.spinner.js"></script>
        <script src="/RIT/js/jquery.jgrowl_minimized.js"></script>
        <script src="/RIT/js/jquery.form.js"></script>
        <script src="/RIT/js/jquery.validate.min.js"></script>
        <script src="/RIT/js/bbq.js"></script>
        <script src="/RIT/js/jquery-ui-1.8.22.custom.min.js"></script>
        <script src="/RIT/js/jquery.form.wizard-min.js"></script>
        <script src="/RIT/js/jquery.cookie.js"></script>
        <script src="/RIT/js/jquery.metadata.js"></script>
        <script src="/RIT/js/custom.js"></script><script src="/RIT/js/demo.js"></script>
        <script src="/RIT/js/iconfont.js"></script>
    </body>
</html>
<%} else {
    out.println("<script>alert('" + session.getAttribute("Enquiry") + "')</script>");
%>
<script type="text/javascript">
    alert("You Are Not Authorised");
    window.history.back();
</script>
<%
            }
        } else {
            request.setAttribute("msg", "You Are Not Authorised! Please Contact to System Administrator!");
            request.setAttribute("value", "0");
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
        }
    } catch (Exception e) {
        request.setAttribute("msg", "Please Contact to System Administrator!");
        request.setAttribute("value", "0");
        getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
%>
